<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*, br.com.caelum.jdbc.modelo.*, br.com.caelum.jdbc.dao.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>lista-contatos-elegante.jsp</title>
	</head>
	<body>
		<c:import url="cabecalho.jsp"/>
		
		<!-- cria o DAO -->
		<jsp:useBean id="dao" class="br.com.caelum.jdbc.dao.ContatoDAO"/>
		
		<table border="1">
			<tr>
				<td>Nome</td>
				<td>Email</td>
				<td>Endereco</td>
				<td>Data Nascimento</td>
			</tr>
			<!-- percorre contatos, montando as linhas da tabela -->
			<c:forEach var="contato" items="${dao.listaContato}">
				<tr>
					<td>${contato.nome}</td>
					<td>
<%-- 						<c:if test="${not empty contato.email}"> --%>
<%-- 							<a href="mailto:${contato.email}">${contato.email }</a> --%>
<%-- 						</c:if> --%>
<%-- 						<c:if test="${empty contato.email }"> --%>
<!-- 							Email nao informado!!! -->
<%-- 						</c:if> --%>
						<c:choose>
							<c:when test="${not empty contato.email }">
								<a href="mailto:${contato.email}">${contato.email }</a> 
							</c:when>
							<c:otherwise>
								Email nao informado!!!
							</c:otherwise>
						</c:choose>
					</td>
					<td>${contato.endereco}</td>
<%-- 					<td>${contato.dataNascimento.time}</td> --%>
					<td><fmt:formatDate value="${contato.dataNascimento.time}" pattern="dd/MM/yyyy"/>
				</tr>
			</c:forEach>
		</table>	
		
		<c:import url="rodape.jsp"></c:import>
	</body>
</html>